/**
 * Copyright (c) 2024 Huawei Technologies Co., Ltd
 * [graph-engine] is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
*/


#ifndef PARSER_COMMON_PASS_MANAGER_H_
#define PARSER_COMMON_PASS_MANAGER_H_

#include <vector>

#include "common/graph_pass.h"

namespace ge {
namespace parser {
///
/// @ingroup domi_omg
/// @brief pass manager
/// @author
///
class PassManager {
public:

  /// get graph passes
  /// @author
  const std::vector<std::pair<std::string, GraphPass *>> &GraphPasses() const;

  /// Add graph pass
  /// @param [in] pass  Pass to be added, it will be destroyed when pass manager destroys.
  /// @author
  Status AddPass(const string &pass_name, GraphPass *const pass);

  /// Optimize graph with added pass
  /// @param [inout] graph graph to be optimized
  /// @return SUCCESS optimize successfully
  /// @return NOT_CHANGED not optimized
  /// @return others optimize failed
  /// @author
  Status Run(const ge::ComputeGraphPtr &graph);

  /// Optimize graph with specified pass
  /// @param [inout] graph graph to be optimized
  /// @param [in] passes passes to be used
  /// @return SUCCESS optimize successfully
  /// @return NOT_CHANGED not optimized
  /// @return others optimized failed
  /// @author
  static Status Run(const ge::ComputeGraphPtr &graph,
                    std::vector<std::pair<std::string, GraphPass *>> &names_to_passes);

  ~PassManager();

private:
  std::vector<std::pair<std::string, GraphPass *>> names_to_graph_passes_;
};
}  // namespace parser
}  // namespace ge
#endif  // PARSER_COMMON_PASS_MANAGER_H_
